package com.bytedance.scenedemo;

import com.bytedance.scene.Scene;
import com.bytedance.scene.animation.animatorexecutor.HorizontalTransitionAnimatorExecutor;
import com.bytedance.scene.interfaces.PushOptions;
import com.bytedance.scene.ktx.SceneExtensions;
import com.bytedance.scene.navigation.NavigationScene;
import com.bytedance.scene.navigation.NavigationSceneOptions;
import com.bytedance.scenedemo.multi_stack.MultiStackTabGroupScene;
import ohos.aafwk.content.Intent;
import ohos.agp.components.*;

/**
 * Created by JiangQi on 8/9/18.
 */
public class MultiStackDemoScene extends Scene {
    @Override
    public Component onCreateView(LayoutScatter layoutScatter, ComponentContainer container, Intent intent) {
        Component layout=layoutScatter.parse(ResourceTable.Layout_navigation_stack_demo,container,false);
        Text textHint= (Text) layout.findComponentById(ResourceTable.Id_text_navigation_stack_hint);
        Button btnDefaultAnimation= (Button) layout.findComponentById(ResourceTable.Id_btn_navigation_stack_default_animation);
        Button btnCustomAnimation= (Button) layout.findComponentById(ResourceTable.Id_btn_navigation_stack_custom_animation);
        Button btnBottomNavigation= (Button) layout.findComponentById(ResourceTable.Id_btn_navigation_stack_bottom_navigation);
        textHint.setText(getClassName());

        btnDefaultAnimation.setClickedListener(component -> {
            SceneExtensions.requireNavigationScene(this).push(NavigationScene.class,new NavigationSceneOptions(MainScene.class,null).toBundle());
        });
        btnCustomAnimation.setClickedListener(component -> {
            SceneExtensions.requireNavigationScene(this).push(NavigationScene.class,new NavigationSceneOptions(MainScene.class,null).toBundle(),
                    new PushOptions.Builder().setAnimation(new HorizontalTransitionAnimatorExecutor()).build());
        });
        btnBottomNavigation.setClickedListener(component -> {
            SceneExtensions.requireNavigationScene(this).push(MultiStackTabGroupScene.class);
        });

        return layout;
    }
}
